#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int ret = INT_MIN;
int dx[4] = { 0 , 0 , 1 , -1 };
int dy[4] = { 1 , -1 , 0 , 0 };
int mem[201][201];
int m, n;

int longestIncreasingPath(vector<vector<int>>& matrix) {
    m = matrix.size();
    n = matrix[0].size();

    for (int i = 0; i < m; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            ret = max(ret, dfs(matrix, i, j));
        }
    }

    return ret;
}

int dfs(vector<vector<int>>& matrix, int i, int j)
{
    int count = 1;
    if (mem[i][j] != 0)
        return mem[i][j];

    for (int k = 0; k < 4; ++k)
    {
        int x = i + dx[k];
        int y = j + dy[k];
        if (x >= 0 && x < m && y >= 0 && y < n && matrix[x][y] > matrix[i][j])
            count = max(count, dfs(matrix, x, y) + 1);
    }

    mem[i][j] = count;
    return count;
}

int main()
{

	return 0;
}